// UVa10003 Cutting Sticks
// 陈锋
#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int MAXN = 50 + 2, INF = 0x7f7f7f7f;
int L, N, C[MAXN], D[MAXN][MAXN];

int dp(int l, int r) {  // O(n^3)
  assert(l < r);
  int &d = D[l][r];
  if (d != -1) return d;
  if (l + 1 == r) return d = 0;
  d = INF;
  for (int i = l + 1; i < r; i++)  // 选择一个点作为切割点
    d = min(C[r] - C[l] + dp(l, i) + dp(i, r), d);
  return d;
}

int main() {
  while (scanf("%d", &L) == 1 && L) {
    scanf("%d", &N);
    C[0] = 0, C[N + 1] = L;
    for(int i = 1; i <= N; i++) scanf("%d", &(C[i]));
    memset(D, -1, sizeof(D));
    int ans = dp(0, N + 1);
    printf("The minimum cutting is %d.\n", ans);
  }
  return 0;
}
/*
算法分析请参考: 《入门经典-第2版》 例题 9-9
*/
// Accepted 150ms 776 C++5.3.02020-12-08 20:36:17 25825819
